<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
  <th:block th:include="include :: header('Select Services')" />
</head>
<body class="gray-bg">
<input type="hidden" id="rowIds">
<div class="container-div">
  <div class="row">
    <div class="col-sm-12 select-table table-striped">
      <table id="bootstrap-table"></table>
    </div>
  </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
  var prefix = ctx + "system/request2";
  var statusDatas = [[${@dict.getType('sys_service_status')}]];

  $(function() {
    var options = {
      url: prefix + "/selServiceList",
      showSearch: false,
      showRefresh: false,
      showToggle: false,
      showColumns: false,
      singleSelect: true,
      columns: [{
        checkbox: true
      },
        {
          field: 'serId',
          title: '主键',
          visible: false
        },
        {
          field: 'serName',
          title: '名称'
        },
        {
          field: 'serDes',
          title: '描述'
        },
        {
          field: 'serStatus',
          title: '状态',
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(statusDatas, value);
          }
        },
        {
          field: 'instrument.instName',
          title: '仪器'
        },
        {
          field: 'serviceType.svtypeName',
          title: '服务类型'
        },
        {
          field: 'createBy',
          title: '创建者'
        },
        {
          field: 'createTime',
          title: '创建时间'
        }]
    };
    $.table.init(options);
  });


  function submitHandler(index, layero) {
    var rows = $.table.selectFirstColumns();
    if (rows.length == 0) {
      $.modal.alertWarning("请至少选择一个服务");
      return;
    }
    $.modal.close();
    // 父页面的方法
    // activeWindow().selectUsers();
    // 父页面的变量
    // activeWindow().$('#input-select').html(rows.join());
  }

  function getSelections() {
    return $.table.selectColumns("serName",false);
  }

  function getIdSelections() {
    return $.table.selectFirstColumns();
  }

  $("#bootstrap-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", function (e, rowsAfter, rowsBefore) {
    var rows = $.common.equals("uncheck-all", e.type) ? rowsBefore : rowsAfter;
    var rowIds = $.table.affectedRowIds(rows);
    $("#rowIds").val(rowIds);
  });
</script>
</body>
</html>